<?php
// +----------------------------------------------------------------------
// | B5LaravelCMF
// +----------------------------------------------------------------------
// | Author: 李恒 <357145480@qq.com>
// +----------------------------------------------------------------------
namespace App\Validates;


use App\Services\WebCatService;

class WebListValidate extends ValidateBase
{
    public function rules()
    {
        return [
            'catid' => 'required',
            'title' => 'required|min:1|max:100'
        ];
    }

    public function attributes()
    {
        return [
            'title' => '信息标题',
            'catid' => '所属菜单'
        ];
    }
    /**
     * 验证标识的唯一性
     * @return ValidateBase
     */
    protected function after_validate()
    {
        if(empty($this->error)){
            $imglist=$this->data['imglist']??[];
            if($imglist){
                $this->data['thumbimg']=$imglist[0];
            }else{
                $this->data['thumbimg']='';
            }
            unset($this->data['imglist']);
            unset($this->data['content']);
        }

        return parent::after_validate(); // TODO: Change the autogenerated stub
    }
}
